<?php
    //
    //  Created by Chagan Anton on 29.07.12.
    //  Copyright Chagan Anton 2012. All rights reserved.
    //
/**
 * This is the model class for table "iphone".
 *
 * The followings are the available columns in table 'iphone':
 * @property integer $id
 * @property string $notification_content
 * @property string $button_label
 * @property integer $badge
 * @property string $sound
 * @property string $action_type
 * @property string $notification_URL
 * @property string $input_text_custom_data
 * @property string $rich_notification_subject
 * @property string $rich_notification_content
 * @property integer $primary_action
 * @property string $primary_action_data
 * @property string $primary_action_button_label
 */
class Iphone extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Iphone the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'iphone';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			//array('notification_content, button_label,  action_type, notification_URL, input_text_custom_data, rich_notification_subject, rich_notification_content, primary_action, primary_action_data, primary_action_button_label', 'required'),
			array('badge, primary_action', 'numerical', 'integerOnly'=>true),
			array('button_label, rich_notification_subject', 'length', 'max'=>18),
			array('sound, primary_action_button_label', 'length', 'max'=>12),
			array('action_type', 'length', 'max'=>1),
			array('notification_URL, primary_action_data', 'length', 'max'=>24),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, notification_content, button_label, badge, sound, action_type, notification_URL, input_text_custom_data, rich_notification_subject, rich_notification_content, primary_action, primary_action_data, primary_action_button_label', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'notification_content' => 'Notification Content',
			'button_label' => 'Button Label',
			'badge' => 'Badge',
			'sound' => 'Sound',
			'action_type' => 'Action Type',
			'notification_URL' => 'Notification Url',
			'input_text_custom_data' => 'Input Text Custom Data',
			'rich_notification_subject' => 'Rich Notification Subject',
			'rich_notification_content' => 'Rich Notification Content',
			'primary_action' => 'Primary Action',
			'primary_action_data' => 'Primary Action Data',
			'primary_action_button_label' => 'Primary Action Button Label',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('notification_content',$this->notification_content,true);
		$criteria->compare('button_label',$this->button_label,true);
		$criteria->compare('badge',$this->badge);
		$criteria->compare('sound',$this->sound,true);
		$criteria->compare('action_type',$this->action_type,true);
		$criteria->compare('notification_URL',$this->notification_URL,true);
		$criteria->compare('input_text_custom_data',$this->input_text_custom_data,true);
		$criteria->compare('rich_notification_subject',$this->rich_notification_subject,true);
		$criteria->compare('rich_notification_content',$this->rich_notification_content,true);
		$criteria->compare('primary_action',$this->primary_action);
		$criteria->compare('primary_action_data',$this->primary_action_data,true);
		$criteria->compare('primary_action_button_label',$this->primary_action_button_label,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}